/*
 * Main.java
 *
 * Created on April 16, 2007, 12:05 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package testnormalapp;

import java.util.Date;
import java.util.List;
import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import usyd.comp5348.CatalogueInfo;
import usyd.comp5348.CatalogueException;
import usyd.comp5348.CatalogueRemote;
import usyd.comp5348.CustomerException;
import usyd.comp5348.CustomerInfo;
import usyd.comp5348.CustomerRemote;
import usyd.comp5348.OrderInfo;
import usyd.comp5348.OrderLineInfo;
import usyd.comp5348.OrderRemote;
import usyd.comp5348.utils.SettingsProvider;

/**
 *
 * @author Yuezhong Zhang
 */
public class Main_1 {
    
    /** Creates a new instance of Main */
    public Main_1() {
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            Properties env1 = new Properties();
            env1.setProperty("org.omg.CORBA.ORBInitialHost","127.0.0.1");
            env1.setProperty("org.omg.CORBA.ORBInitialPort","3700");
            InitialContext central = new InitialContext( env1 );
            CustomerInfo cinfo = new CustomerInfo("fred", "123 address");
            CustomerRemote custrem = (CustomerRemote)central.lookup("ejb/Customer");
            cinfo.setId(custrem.createCustomer(cinfo));
            OrderRemote or = (OrderRemote)central.lookup("ejb/Order");
            try {
                OrderLineInfo [] oline = new OrderLineInfo[1];
                oline[0]=new OrderLineInfo(1, 10);
                OrderInfo oi = new OrderInfo(cinfo.getId(), 22.0f, oline, new Date(), "127.0.0.1", OrderInfo.SUBMITTED);
                oi.setId(or.createOrder(oi));
                System.err.println("O: " + oi.getId());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}
